<template>
	<uni-popup ref="popup" type="bottom">
		<view class="content column">
			<text class="mix-icon icon-guanbi" @click="close"></text>
			<view class="pro-info column center">
				<view class="right column">
					<text class="title">我的成绩</text>
				</view>
			</view>
				<!-- 规格 -->
			<scroll-view class="c-wrap " scroll-y="true">
				<view class="score-wrap row center">
					<input class="input score" v-model="game.gamePlayer.scoreStr" @input="handleInput"  maxlength="20" placeholder-class="placeholder">
					<text class="s-tit fill">单位：{{game.scoreTypeTxt}}</text>
				</view>
				<text class="txt">比赛结束后24小时内没有上传成绩的钓手，默认最后一名</text>
			</scroll-view>
			<view class="btn-wrap row">
				<view class="confirm-btn center" @click="confirm()">
					<text>提交</text>
				</view>
			</view>
		</view>
	</uni-popup>
</template>

<script>
	import {getUnique} from '@/common/js/util'
	export default {
		data() {
			return {
				type: '', //cart加入购物车 buy立即购买
				score: 0,
			}
		},
		props: {
			player: {
				type: Object,
				default(){
					return {}
				}
			},
			infoData: {
				type: Object,
				default(){
					return {}
				}
			},
			game: {
				type: Object,
				default(){
					return {}
				}
			},
		},
		watch: {
			player(player){
				// console.log("=watch=player=="+JSON.stringify(player.score))
				this.socre = player.score;
			},
			game(game){
				// this.score = Number(game.gamePlayer.scoreStr)
			},
		},
		created() {
		},
		methods: {
			//结算
			confirm(){
				// console.log("==onSubmitPlayerScore=="+JSON.stringify(this.player))
				if(!/^[0-9,.]*$/.test(this.score)){
				  this.$util.msg("请输入正确的赛事成绩");
				  return ;
				}else{
					this.game.gamePlayer.scoreStr = this.score;
					this.$emit("onSubmitPlayerScore", this.game.gamePlayer);
				}
				// this.player.score = this.score;
				// this.$emit("onSubmitPlayerScore", this.game);
			},
			handleInput(e) {
				console.log("handleInput"+JSON.stringify(e))
				let val = e.target.value;
				if(!/^[0-9,.]*$/.test(val)){
				  this.$util.msg("请输入正确的赛事成绩");
				}
				this.score = val;
			},
			open(type){
				this.type = typeof type === 'string' ? type: '';
				this.$refs.popup.open();
			},
			close(){
				this.$refs.popup.close();
			}
		}
	}
</script>

<style scoped lang="scss">
	.content{
		width: 750rpx;
		background-color: #fff;
		border-radius: 10rpx 10rpx 0 0;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom); 
		position: relative;
	}
	.icon-guanbi{
		position: absolute;
		right: 10rpx;
		top: 10rpx;
		padding: 20rpx;
		font-size: 32rpx;
		color: #999;
	}
	.pro-info{
		padding: 30rpx 32rpx 16rpx;
		.title{
			color: #0081FF;
			font-size: 32rpx;
			margin: 30rpx 0rpx;
		}
		.attr-wrap{
			flex-wrap: wrap;
			
			text{
				line-height: 1.4;
				font-size: 24rpx;
				color: #333;
			}
			.attr{
				flex-shrink: 0;
				margin-right: 10rpx;
				color: #999;
				
				&.checked{
					color: #333;
				}
			}
		}
	}
	.s-tit{
		margin-left: 42rpx;
		font-size: 30rpx;
		color: #333;
		font-weight: 700;
		line-height: 90rpx;
	}
	.c-wrap{
		display: flex;
		flex-direction: row; 
		justify-content: center;
		margin-bottom: 20rpx;
		.txt{
			width: 100%;
			// font-size: 24rpx;
			// margin: 10rpx 10rpx 10rpx 20rpx;
			display: flex;
			flex-direction: row; 
			justify-content: center;
			padding: 20rpx;
			color: #888888;
		}
		
	}
	.score-wrap{
		margin-left: 15%;
		// display: flex;
		// flex-direction: row; 
		// justify-content: center;
		.score{
			height: 60rpx;
			padding-left: 10rpx;
			border: 1px solid #878787;
			border-radius: 10rpx;
			font-size: 32rpx;
		}
		
	}
	
	.btn-wrap{
		align-items: flex-end;
		justify-content: center;
		padding: 36rpx 0 30rpx;
	}
	.confirm-btn{
		width: 670rpx;
		height: 84rpx;
		background-color: $base-color;
		font-size: 32rpx;
		color: #fff;
		border-radius: 100rpx;
	}
	.sm{
		width: 670rpx;
		margin: 0 auto;
		
		.btn{
			flex: 1;
			height: 84rpx;
			font-size: 32rpx;
			color: #fff;
			background-color: orange;
			border-radius: 100rpx 0 0 100rpx;
			
			&:last-child{
				background-color: $base-color;
				border-radius: 0 100rpx 100rpx 0;
			}
		}
	}
</style>
